  <extend name="Public/base"/>
  <block name="style">
    <!--此页面增加的style-->
  </block>

  <block name="body">

        <div class="builder-tabs builder-form-tabs">
            <ul class="nav nav-tabs">
                <li class=""><a href="{:U('role_edit',array('group_id'=>$role_id))}">角色信息</a></li>
                <li class=""><a href="{:U('access',array('group_id'=>$role_id))}">权限分配</a></li>
                <li class=""><a href="{:U('accessUser',array('group_id'=>$role_id))}">成员授权</a></li>
            </ul>
            <div class="form-group"></div>
        </div>

    <div class="builder formbuilder-box panel-body bg-color-fff">

    <div class="row">    

        <div class="col-md-7 col-md-offset-2">      

                        <div id="tab2" class="tab-pane">
                        <form action="__SELF__" method="post" class="form-builder form-horizontal responsive" >
                            <div class="form-group">
                                <div class="auth">
                                    <volist name="all_auth_rules" id="vo1">
                                        <?php $module_name = $vo1['module']; ?>
                                        <div class="{$module_name}">
                                            <div class="ud-control ud-checkbox">
                                                <label class="checkbox-label checkbox-inline">
                                                    <input type="checkbox" name="menu_auth[]" data-module-name="{$module_name}" <php>if(in_array($vo1['id'], $menu_auth_rules)) echo "checked";</php> value="{$vo1.id}">
                                                    <span class="ud-control-indicator"></span>
                                                    <span> {$vo1.title}</span>
                                                </label>
                                                <div class="auth{$vo1.id}" style="padding-left: 25px;margin-top: 10px;">
                                                    <volist name="vo1._child" id="vo2">
                                                        <label class="checkbox-label checkbox-inline">
                                                            <input type="checkbox" name="menu_auth[]" data-module-name="{$module_name}" <php>if(in_array($vo2['id'], $menu_auth_rules)) echo "checked";</php> value="{$vo2.id}">
                                                            <span class="ud-control-indicator"></span>
                                                            <span> {$vo2.title}</span>
                                                        </label>
                                                        <div class="auth{$vo2.id}" style="padding-left: 25px;margin-top: 10px;">
                                                            <foreach name="vo2._child" item="vo3">
                                                                <label class="checkbox-label checkbox-inline">
                                                                    <input type="checkbox" name="menu_auth[]" data-module-name="{$module_name}" <php>if(in_array($vo3['id'], $menu_auth_rules)) echo "checked";</php> value="{$vo3.id}">
                                                                    <span class="ud-control-indicator"></span>
                                                                    <span> {$vo3.title}</span>
                                                                </label>
                                                                <notempty name="vo3._child">
                                                                    <div class="auth{$vo3.id}" style="padding-left: 25px;margin-top: 10px;margin-bottom: 10px;">
                                                                        <volist name="vo3._child" id="vo4">
                                                                            <notempty name="vo4._child">
                                                                                <label class="checkbox-inline" style="display: block;margin-top: 10px;margin-left: 0px;">
                                                                                    <input type="checkbox" name="menu_auth[]" data-module-name="{$module_name}" <php>if(in_array($vo4['id'], $menu_auth_rules)) echo "checked";</php> value="{$vo4.id}">
                                                                                    <span class="ud-control-indicator"></span>
                                                                                    <span> {$vo4.title}</span>
                                                                                </label>
                                                                            <else />
                                                                                 <label class="checkbox-inline">
                                                                                    <input type="checkbox" name="menu_auth[]" data-module-name="{$module_name}" <php>if(in_array($vo4['id'], $menu_auth_rules)) echo "checked";</php> value="{$vo4.id}">
                                                                                    <span class="ud-control-indicator"></span>
                                                                                    <span> {$vo4.title}</span>
                                                                                </label>
                                                                            </notempty>
                                                                            <notempty name="vo4._child">
                                                                                <div class="auth{$vo4.id}" style="padding-left: 25px;margin-top: 10px;margin-bottom: 10px;">
                                                                                    <foreach name="vo4._child" item="vo5">
                                                                                        <label class="checkbox-inline">
                                                                                            <input type="checkbox" name="menu_auth[]" data-module-name="{$module_name}" <php>if(in_array($vo5['id'],$menu_auth_rules)) echo "checked";</php> value="{$vo5.id}">
                                                                                            <span class="ud-control-indicator"></span>
                                                                                            <span> {$vo5.title}</span>
                                                                                        </label>
                                                                                    </foreach>
                                                                                </div>
                                                                            </notempty>
                                                                        </volist>
                                                                    </div>
                                                                </notempty>
                                                            </foreach>
                                                        </div>
                                                    </volist>
                                                </div>
                                            </div>
                                        </div>
                                        <hr>
                                    </volist>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-md-10 col-md-offset-2 tc">
                                     <button class="radius ud-button bg-color-blue submit ajax-post ud-shadow" type="submit" target-form="form-builder">确认</button>  &nbsp;
                              </div>
                            </div>
                        </form>
                </div>
                    
            </div>    
   </div><!--row-->
 </div>

  </block>

  <block name="script">
    <script type="text/javascript">
        $(function(){
            //遍历选中当前权限的子权限
            $('.auth input[type="checkbox"]').on('change',function(){
                $('.'+$(this).attr('data-module-name')+' .auth'+$(this).val()).find('input').prop('checked',this.checked);
            });
        });
    </script>
  </block>